

inherit "inherit/object"

number isLoad = 0;

number isRoom = 1;

var heartbeat(){


}





number load(){

    println("load了!!" + baseName(this));

    initObjects();
    initExits();
}

number initObjects(){
    map obs = query("objects");
    if( !mapp(obs) ) return 1;
    var k = keys(obs);
    foreach( p in k ){
        number n = obs[p];
        for(number i;i < n; i++){
            object obj  = make(p);
            obj.move(this);
        }
    }

}

//初始化出口数据,将连接更换为对象地址
number initExits(){

   var exits;
   println(baseName(this)+"执行出口初始化");
   if( mapp( (exits = query("exits")) ) ){
        string ks  = keys(exits);
        object r;
        foreach( p in ks ){
             if( strsrch(exits[p],"#") < 0 ){
                //房间 永远都是唯一的 所有 先加载，没有才创建
                r = loadObject(exits[p]);
                exits[p] = r.query("fileAddr");
                println("initExits "+ r.query("fileAddr"));
//                r.refsExit(toObj(this));
             }
//
        }
   }
}


number refsExit(object room){
     var exits;
      if( mapp( (exits = query("exits")) ) ){
           string ks  = keys(exits);
           object r;
           foreach( p in ks ){
                if( strsrch(exits[p],"#") < 0 && exits[p]==baseName(room)){
                   exits[p] = room.query("fileAddr");
                   println("更新了房间"+exits[p]);
                }
           }
      }
}


